home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / snip1292.zip / ANSISCRN.H < prev    next >
C/C++ Source or Header  |  1992-12-26  |  2KB  |  73 lines

  1. #ifndef   ANSISCRN
  2. #define   ANSISCRN
  3. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4.  *
  5.  *       ANSISCRN.H
  6.  *
  7.  *       #include implementation of ANSI screen control codes
  8.  *            Contributed to the public domain 12-26-91 by
  9.  *              Matthew J. Glass.
  10.  *
  11.  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  12.  
  13. #include   <stdio.h>
  14.  
  15. #define   ESC                  27
  16. #define   ANSI_cup(a,b)        printf("%c[%d;%dH",ESC,a,b)
  17. #define   ANSI_up(a)           printf("%c[%dA",ESC,a)
  18. #define   ANSI_down(a)         printf("%c[%dB",ESC,a)
  19. #define   ANSI_right(a)        printf("%c[%dC",ESC,a)
  20. #define   ANSI_left(a)         printf("%c[%dD",ESC,a)
  21. #define   ANSI_locate(a,b)     printf("%c[%d;%df",ESC,a,b)
  22. #define   ANSI_savecurs()      printf("%c[S",ESC)
  23. #define   ANSI_restcurs()      printf("%c[U",ESC)
  24. #define   ANSI_cls()           printf("%c[2J",ESC)
  25. #define   ANSI_cleol()         printf("%c[K",ESC)
  26. #define   ANSI_margins(a,b)    printf("%c[%d;%dr",ESC,a,b)
  27.  
  28. #define   NORMAL         0     /* attributes for ANSI_attrib() */
  29. #define   BOLD           1
  30. #define   USCORE         2
  31. #define   BLINK          3
  32. #define   REVERSE        4
  33. #define   INVIS          5
  34.  
  35. #define   BLACK          0     /* colors for ANSI_bg_color() and */
  36. #define   RED            1     /* ANSI_fg_color.                 */
  37. #define   GREEN          2
  38. #define   YELLOW         3
  39. #define   BLUE           4
  40. #define   MAGENTA        5
  41. #define   CYAN           6
  42. #define   WHITE          7
  43. #define   B_BLACK        8     /* bright colors for ANSI_fg_color() */
  44. #define   B_RED          9
  45. #define   B_GREEN        10
  46. #define   B_YELLOW       11
  47. #define   B_BLUE         12
  48. #define   B_MAGENTA      13
  49. #define   B_CYAN         14
  50. #define   B_WHITE        15
  51.  
  52. static char *_atrb_plt[] = {
  53.    "0","1","4","5","7","8"
  54.    };
  55.  
  56. static char *_fg_plt[] = {
  57.    "0;30","0;31","0;32","0;33",
  58.    "0;34","0;35","0;36","0;37",
  59.    "1;30","1;31","1;32","1;33",
  60.    "1;34","1;35","1;36","1;37"
  61.    };
  62.  
  63. static char *_bg_plt[] = {
  64.    "40","41","42","43",
  65.    "44","45","46","47"
  66.     };
  67.  
  68. #define   ANSI_attrib(a)     printf("%c[%sm",ESC,_atrb_plt[a])
  69. #define   ANSI_fg_color(a)   printf("%c[%sm",ESC, _fg_plt[a] )
  70. #define   ANSI_bg_color(a)   printf("%c[%sm",ESC, _bg_plt[a] )
  71.  
  72. #endif /* ANSISCRN */
  73.